<?php
 defined("BASEDIR") or die();
 
 class Application_Controller_Default implements Application_Interface_Action
 {
	protected $view, $request, $modInfo;
	public function __construct(Application_Router_Standard_Request $request)
	{
		$this->request = $request;
		$this->view = Application_View_ViewEngine::getInstance();
		
		if(is_readable("../application/module_info/".$request->controller."info.php"))
		{
			include_once("../application/module_info/".$request->controller."info.php");
			$this->modInfo = $mod;
			$this->view->assign_by_ref("module_title", $this->modInfo['title']);
		}
		$actionName = $request->action."Action";
		if(method_exists($this, $actionName))
			$this->$actionName();
		else
			$this->defaultAction();
		$this->view->assign("module", $request->action);
		$this->view->assign("addcss", $request->controller);
		
		$ses = Application_Model_SessionControl::getInstance();
		if($ses->logged_in) { 
			$this->view->assign("zalogowany", true);
			$this->view->assign("username", $ses->username);
		}
		if($this->request->blank != 1)
			$this->view->render();
	}
	public function defaultAction()
	{
		$user = Application_Router_Standard_User::getInstance($this->request);
		if($user->level < $this->modInfo['requiredLevel'])
			$this->request->action = "notallowed";
		else
			$this->request->action = $this->request->controller;
	}
 }
?>